package com.unittec.zk.provider.utils;

import com.alibaba.fastjson.JSONObject;
import com.unittec.zk.provider.scope.ThreadLocalScope;
import com.unittec.zk.provider.ApplicationContextProvider;
import org.springframework.stereotype.Component;

@Component
public class SmsUtil {
    public JSONObject sendSms(String mobileString, JSONObject paramJson, String templateId) {
        AsyncSendSms asyncSendSms = ApplicationContextProvider.getApplicationContext().getBean(AsyncSendSms.class);
        ThreadLocalScope.AuthData authData = ThreadLocalScope.getAuthData();
        JSONObject json = new JSONObject();
        try {
            asyncSendSms.asyncSendSms(authData, mobileString, paramJson, templateId);
        } catch (Exception e) {
            json.put("code", "00001");
            json.put("message", "发送短信失败");
            return json;
        }
        json.put("code", "00000");
        return json;
    }

}
